<?
/**
 * VoiceOne Sounds
 *
 * Frontend to play audio file
 * @package voiceone
 * @subpackage  sounds
 * @todo Needs documentation and implementation
 */
 	$noSession=true;
  include ("../../../admin/config/cfg.php");
  global $cwBasePath,$cwlang;

//----------------------------------- GET --------------------------------------
  if(count($_GET)==2){
    // Define relative path (path next to /voiceone_webservices/sandbox)
    $label=$_GET["filename"];
    $filepath="/".$_GET["filename"];
    // if web service is active the file_content is ready to use
    if($soapWrapper===false){
      $file_content=$asterisk->getFileFromSandbox($filepath);
    }
    // if web service is emulated the file_content have to be decoded
    else{
      $file_content=$asterisk->getFileFromSandbox($filepath);
      $file_content=base64_decode($file_content);
    }
    if($file_content!=""){
      header('Content-Type: '.'application/x-gzip');
      header('Content-Disposition: attachment; filename="'.$label.'"'); 
      echo $file_content;
    } 
 		echo "Error opening backup file: <strong>".$_GET["filename"]."</strong>";
  }
?>
